<!DOCTYPE html><html lang="en"><head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <meta content="CR" name="w3c-status">
  <title>HTML 5.1: 9. The XHTML syntax</title>
  <link href="styles/styles-html.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href=styles.default.css>
  <meta content="Bikeshed 1.0.0" name="generator">

  <link href="styles/W3C-CR" rel="stylesheet" type="text/css">
 </head>
 <body class="h-entry">
  <div class="head">
   <header>
    <p data-fill-with="logo"><a href="http://www.w3.org/"><img alt="W3C" height="48" src="styles/logos/W3C" width="72"></a></p>
    <h1 class="p-name no-ref allcaps" id="title">HTML 5.1</h1>
    <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">W3C Candidate Recommendation, <time class="dt-updated" datetime="2016-06-21">21 June 2016</time></span></h2>
   </header>
   
   
   
   
  </div>
  
  
  
  
  
  <nav data-fill-with="table-of-contents" id="toc"><p class="prev_next">← <a href="syntax.html#syntax"><span class="secno">8</span> <span class="content"><span>The HTML syntax</span></span></a> — <a href="index.html#contents">Table of contents</a> — <a href="rendering.html#rendering"><span class="secno">10</span> <span class="content">Rendering</span></a> →</p>
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory"><li>
     <a href="xhtml.html#xhtml"><span class="secno">9</span> <span class="content"><span>The XHTML syntax</span></span></a>
     <ol class="toc">
      <li><a href="xhtml.html#writing-xhtml-documents"><span class="secno">9.1</span> <span class="content">Writing XHTML documents</span></a>
      </li><li><a href="xhtml.html#parsing-xhtml-documents"><span class="secno">9.2</span> <span class="content">Parsing XHTML documents</span></a>
      </li><li><a href="xhtml.html#serializing-xhtml-fragments"><span class="secno">9.3</span> <span class="content">Serializing XHTML fragments</span></a>
      </li><li><a href="xhtml.html#parsing-xhtml-fragments"><span class="secno">9.4</span> <span class="content">Parsing XHTML fragments</span></a>
     </li></ol>
    </li></ol>
  </nav><main><section>
    <h2 class="heading settled" data-level="9" id="xhtml"><span class="secno">9. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-xhtml-syntax">The XHTML syntax</dfn></span><a class="self-link" href="xhtml.html#xhtml"></a></h2>
    <p class="note" role="note"> This section only describes the rules for XML resources. Rules for <a href="iana.html#text-html"><code>text/html</code></a> resources are discussed in the section above entitled "<a data-link-type="dfn" href="syntax.html#the-html-syntax" id="ref-for-the-html-syntax-1">The HTML syntax</a>". </p>
    <div class="impl">
     <h3 class="heading settled" data-level="9.1" id="writing-xhtml-documents"><span class="secno">9.1. </span><span class="content">Writing XHTML documents</span><a class="self-link" href="xhtml.html#writing-xhtml-documents"></a></h3>
    </div>
    <p>The syntax for using HTML with XML, whether in XHTML documents or embedded in other XML
  documents, is defined in the XML and Namespaces in XML specifications. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a></p>
    <p>This specification does not define any syntax-level requirements beyond those defined for XML
  proper.</p>
    <p>XML documents may contain a <code>DOCTYPE</code> if desired, but this is not required
  to conform to this specification. This specification does not define a public or system
  identifier, nor provide a formal DTD.</p>
    <p class="note" role="note"> According to the XML specification, XML processors are not guaranteed to process
  the external DTD subset referenced in the DOCTYPE. This means, for example, that using <a data-link-type="dfn" href="https://www.w3.org/TR/xml/#dt-entref">entity references</a> for characters in XHTML documents
  is unsafe if they are defined in an external file (except for <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;quot;</code> and <code>&amp;apos;</code>). </p>
    <div class="impl">
     <h3 class="heading settled" data-level="9.2" id="parsing-xhtml-documents"><span class="secno">9.2. </span><span class="content">Parsing XHTML documents</span><a class="self-link" href="xhtml.html#parsing-xhtml-documents"></a></h3>
     <p>This section describes the relationship between XML and the DOM, with a particular emphasis on
  how this interacts with HTML.</p>
     <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="xml-parser">XML parser</dfn>, for the purposes of this specification, is a construct that follows
  the rules given in the XML specification to map a string of bytes or characters into a <code>Document</code> object.</p>
     <p class="note" role="note"> At the time of writing, no such rules actually exist. </p>
     <p>An <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-21">XML parser</a> is either associated with a <code>Document</code> object when it is
  created, or creates one implicitly.</p>
     <p>This <code>Document</code> must then be populated with DOM nodes that represent the tree
  structure of the input passed to the parser, as defined by the XML specification, the Namespaces
  in XML specification, and the DOM specification. DOM mutation events must not fire for the
  operations that the <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-22">XML parser</a> performs on the <code>Document</code>’s tree, but the
  user agent must act as if elements and attributes were individually appended and set respectively
  so as to trigger rules in this specification regarding what happens when an element is inserted
  into a document or has its attributes set, and the DOM specification’s requirements regarding
  mutation observers mean that mutation observers <em>are</em> fired (unlike mutation events). <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a> <a data-link-type="biblio" href="references.html#biblio-dom">[DOM]</a> <a data-link-type="biblio" href="references.html#biblio-uievents">[UIEVENTS]</a></p>
     <p>Between the time an element’s start tag is parsed and the time either the element’s end tag is
  parsed or the parser detects a well-formedness error, the user agent must act as if the element
  was in a <a data-link-type="dfn" href="syntax.html#stack-of-open-elements" id="ref-for-stack-of-open-elements-204">stack of open elements</a>.</p>
     <p class="note" role="note"> This is used, e.g., by the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-object" id="ref-for-elementdef-object-84">object</a></code> element to avoid instantiating plugins
  before the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-param" id="ref-for-elementdef-param-10">param</a></code> element children have been parsed. </p>
     <p>This specification provides the following additional information that user agents should use
  when retrieving an external entity: the public identifiers given in the following list all
  correspond to <a href="entities.dtd">the URL given by this link</a>. (This
  URL is a DTD containing the <a data-link-type="dfn" href="https://www.w3.org/TR/xml/#sec-entity-decl">entity declarations</a> for the names listed in the <a href="syntax.html#named-character-references">§8.5 Named character references</a> section.) <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a></p>
     <ul class="brief">
      <li><code>-//W3C//DTD XHTML 1.0 Transitional//EN</code>
      </li><li><code>-//W3C//DTD XHTML 1.1//EN</code>
      </li><li><code>-//W3C//DTD XHTML 1.0 Strict//EN</code>
      </li><li><code>-//W3C//DTD XHTML 1.0 Frameset//EN</code>
      </li><li><code>-//W3C//DTD XHTML Basic 1.0//EN</code>
      </li><li><code>-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN</code>
      </li><li><code>-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN</code>
      </li><li><code>-//W3C//DTD MathML 2.0//EN</code>
      </li><li><code>-//WAPFORUM//DTD XHTML Mobile 1.0//EN</code>
     </li></ul>
     <p>Furthermore, user agents should attempt to retrieve the above external entity’s content when
  one of the above public identifiers is used, and should not attempt to retrieve any other external
  entity’s content.</p>
     <p class="note" role="note"> This is not strictly a <a data-link-type="dfn" href="introduction.html#willful-violation" id="ref-for-willful-violation-6">violation</a> of the XML
  specification, but it does contradict the spirit of the XML specification’s requirements. This is
  motivated by a desire for user agents to all handle entities in an interoperable fashion without
  requiring any network access for handling external subsets. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> </p>
     <p>XML parsers can be invoked with <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="XML scripting support disabled|XML scripting support enabled" data-noexport="" id="xml-scripting-support-disabled">XML scripting support enabled or disabled</dfn>. Except where otherwise specified, XML parsers are
  invoked with <a data-link-type="dfn" href="xhtml.html#xml-scripting-support-disabled" id="ref-for-xml-scripting-support-disabled-1">XML scripting support enabled</a>.</p>
     <p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-23">XML parser</a> with <a data-link-type="dfn" href="xhtml.html#xml-scripting-support-disabled" id="ref-for-xml-scripting-support-disabled-2">XML scripting support enabled</a> creates a <code><a data-link-type="element" href="semantics-scripting.html#elementdef-script" id="ref-for-elementdef-script-130">script</a></code> element, it
  must be marked as being <a data-link-type="dfn" href="semantics-scripting.html#parser-inserted" id="ref-for-parser-inserted-16">"parser-inserted"</a> and its <a data-link-type="dfn" href="semantics-scripting.html#non-blocking" id="ref-for-non-blocking-10">"non-blocking"</a> flag
  must be unset. If the parser was originally created for the <a data-link-type="dfn" href="xhtml.html#xml-fragment-parsing-algorithm" id="ref-for-xml-fragment-parsing-algorithm-1">XML fragment parsing
  algorithm</a>, then the element must be marked as <a data-link-type="dfn" href="semantics-scripting.html#already-started" id="ref-for-already-started-7">"already started"</a> also. When the
  element’s end tag is subsequently parsed, the user agent must <a data-link-type="dfn" href="webappapis.html#performs-a-microtask-checkpoint" id="ref-for-performs-a-microtask-checkpoint-9">perform a microtask checkpoint</a>, and
  then prepare the <code><a data-link-type="element" href="semantics-scripting.html#elementdef-script" id="ref-for-elementdef-script-131">script</a></code> element. If this
  causes there to be a <a data-link-type="dfn" href="semantics-scripting.html#pending-parsing-blocking-script" id="ref-for-pending-parsing-blocking-script-10">pending parsing-blocking script</a>, then the user agent must run
  the following steps:</p>
     <ol>
      <li>Block this instance of the <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-24">XML parser</a>, such that the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-91">event loop</a> will not run <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-124">tasks</a> that invoke it.
      </li><li><a data-link-type="dfn" href="webappapis.html#spinning-the-event-loop" id="ref-for-spinning-the-event-loop-11">Spin the event loop</a> until the parser’s <code>Document</code> <a data-link-type="dfn" href="document-metadata.html#has-no-style-sheet-that-is-blocking-scripts" id="ref-for-has-no-style-sheet-that-is-blocking-scripts-3">has no
    style sheet that is blocking scripts</a> and the <a data-link-type="dfn" href="semantics-scripting.html#pending-parsing-blocking-script" id="ref-for-pending-parsing-blocking-script-11">pending parsing-blocking
    script</a>’s <a data-link-type="dfn" href="semantics-scripting.html#ready-to-be-parser-executed" id="ref-for-ready-to-be-parser-executed-7">"ready to be parser-executed"</a> flag is set.
      </li><li>Unblock this instance of the <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-25">XML parser</a>, such that <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-125">tasks</a> that invoke it can again be run.
      </li><li><a data-link-type="dfn" href="semantics-scripting.html#execute-a-script-block" id="ref-for-execute-a-script-block-6">Execute</a> the <a data-link-type="dfn" href="semantics-scripting.html#pending-parsing-blocking-script" id="ref-for-pending-parsing-blocking-script-12">pending parsing-blocking
    script</a>.
      </li><li>There is no longer a <a data-link-type="dfn" href="semantics-scripting.html#pending-parsing-blocking-script" id="ref-for-pending-parsing-blocking-script-13">pending parsing-blocking script</a>.
     </li></ol>
     <p class="note" role="note"> Since the <a class="idl-code" data-link-type="method" href="webappapis.html#dom-document-write" id="ref-for-dom-document-write-23"><code>document.write()</code></a> API is not
  available for <a data-link-type="dfn" href="infrastructure.html#xml-document" id="ref-for-xml-document-26">XML documents</a>, much of the complexity in the <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-52">HTML parser</a> is not needed in the <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-26">XML parser</a>. </p>
     <p class="note" role="note"> When the <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-27">XML parser</a> has <a data-link-type="dfn" href="xhtml.html#xml-scripting-support-disabled" id="ref-for-xml-scripting-support-disabled-3">XML scripting support disabled</a>,
  none of this happens. </p>
     <p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-28">XML parser</a> would append a node to a <code><a data-link-type="element" href="semantics-scripting.html#elementdef-template" id="ref-for-elementdef-template-51">template</a></code> element, it must instead append it to the <code><a data-link-type="element" href="semantics-scripting.html#elementdef-template" id="ref-for-elementdef-template-52">template</a></code> element’s <a data-link-type="dfn" href="semantics-scripting.html#template-contents" id="ref-for-template-contents-17">template contents</a> (a <code>DocumentFragment</code> node).</p>
     <p class="note" role="note"> This is a <a data-link-type="dfn" href="introduction.html#willful-violation" id="ref-for-willful-violation-7">willful violation</a> of the XML specification; unfortunately,
  XML is not formally extensible in the manner that is needed for <code>template</code> processing. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> </p>
     <p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-29">XML parser</a> creates a <code>Node</code> object, its <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a> must be set to the <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a> of
  the node into which the newly created node is to be inserted.</p>
     <p>Certain algorithms in this specification <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="feed the parser|spoon-feed the parser" data-noexport="" id="feed-the-parser">spoon-feed the
  parser</dfn> characters one string at a time. In such cases, the <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-30">XML parser</a> must act
  as it would have if faced with a single string consisting of the concatenation of all those
  characters.</p>
     <p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-31">XML parser</a> reaches the end of its input, it must <a data-link-type="dfn" href="syntax.html#stopped" id="ref-for-stopped-17">stop
  parsing</a>, following the same rules as the <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-53">HTML parser</a>. An <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-32">XML
  parser</a> can also be <a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-11">aborted</a>, which must again be done in
  the same way as for an <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-54">HTML parser</a>.</p>
     <p>For the purposes of conformance checkers, if a resource is determined to be in <a href="xhtml.html#xhtml">the XHTML syntax</a>, then it is an <a data-link-type="dfn" href="infrastructure.html#xml-document" id="ref-for-xml-document-27">XML document</a>.</p>
     <h3 class="heading settled" data-level="9.3" id="serializing-xhtml-fragments"><span class="secno">9.3. </span><span class="content">Serializing XHTML fragments</span><a class="self-link" href="xhtml.html#serializing-xhtml-fragments"></a></h3>
     <p>The <dfn data-dfn-type="dfn" data-noexport="" id="xml-fragment-serialization-algorithm">XML fragment serialization algorithm<a class="self-link" href="xhtml.html#xml-fragment-serialization-algorithm"></a></dfn> for a <code>Document</code> or <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#interface-element">Element</a></code> node either returns a fragment of XML that represents that node or throws an
  exception.</p>
     <p>For <code>Document</code>s, the algorithm must return a string in the form of a <a data-link-type="dfn" href="https://www.w3.org/TR/xml/#sec-well-formed">document entity</a>, if none of the error cases
  below apply.</p>
     <p>For <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#interface-element">Element</a></code>s, the algorithm must return a string in the form of an <a data-link-type="dfn" href="https://www.w3.org/TR/xml/#wf-entities">internal general parsed entity</a>, if none of the
  error cases below apply.</p>
     <p>In both cases, the string returned must be XML namespace-well-formed and must be an isomorphic
  serialization of all of that node’s <a data-link-type="dfn" href="xhtml.html#relevant-child-nodes" id="ref-for-relevant-child-nodes-1">relevant child nodes</a>, in <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-81">tree order</a>.
  User agents may adjust prefixes and namespace declarations in the serialization (and indeed might
  be forced to do so in some cases to obtain namespace-well-formed XML). User agents may use a
  combination of regular text and character references to represent <code>Text</code> nodes in the
  DOM.</p>
     <p>A node’s <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="relevant-child-nodes">relevant child nodes</dfn> are those that apply given the following rules:</p>
     <dl>
      <dt>For <code><a data-link-type="element" href="semantics-scripting.html#elementdef-template" id="ref-for-elementdef-template-53">template</a></code> elements
      </dt><dd>The <a data-link-type="dfn" href="xhtml.html#relevant-child-nodes" id="ref-for-relevant-child-nodes-2">relevant child nodes</a> are the child nodes of the <code>template</code> element’s <a data-link-type="dfn" href="semantics-scripting.html#template-contents" id="ref-for-template-contents-18">template contents</a>, if any.
      </dd><dt>For all other nodes
      </dt><dd>The <a data-link-type="dfn" href="xhtml.html#relevant-child-nodes" id="ref-for-relevant-child-nodes-3">relevant child nodes</a> are the child nodes of node itself, if any.
     </dd></dl>
     <p>For <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#interface-element">Element</a></code>s, if any of the elements in the serialization are in no namespace, the
  default namespace in scope for those elements must be explicitly declared as the empty string. (This doesn’t apply in the <code>Document</code> case.) <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a></p>
     <p>For the purposes of this section, an internal general parsed entity is considered XML
  namespace-well-formed if a document consisting of an element with no namespace declarations whose
  contents are the internal general parsed entity would itself be XML namespace-well-formed.</p>
     <p>If any of the following error cases are found in the DOM subtree being serialized, then the
  algorithm must throw an <code>InvalidStateError</code> exception instead of returning a
  string:</p>
     <ul>
      <li>A <code>Document</code> node with no child element nodes.
      </li><li>A <code>DocumentType</code> node that has an external subset public identifier that contains
    characters that are not matched by the XML <code>PubidChar</code> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
      </li><li>A <code>DocumentType</code> node that has an external subset system identifier that contains
    both a U+0022 QUOTATION MARK (") and a U+0027 APOSTROPHE (') or that contains characters that are
    not matched by the XML <code>Char</code> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
      </li><li>A node with a  local name containing a U+003A COLON (:).
      </li><li>A node with a  local name that does not match the XML <a data-link-type="dfn" href="https://www.w3.org/TR/xml/#NT-Name"><code>Name</code></a> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
      </li><li>An <code>Attr</code> node with no namespace whose local name is the lowercase string "<code>xmlns</code>". <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a>
      </li><li>An <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#interface-element">Element</a></code> node with two or more attributes with the same local name and
    namespace.
      </li><li>An <code>Attr</code> node, <code>Text</code> node, <code>Comment</code> node, or <code>ProcessingInstruction</code> node whose data contains characters that are not matched by
    the XML <code>Char</code> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
      </li><li>A <code>Comment</code> node whose data contains two adjacent U+002D HYPHEN-MINUS characters
    (-) or ends with such a character.
      </li><li>A <code>ProcessingInstruction</code> node whose target name is an <a data-link-type="dfn" href="infrastructure.html#ascii-case-insensitive" id="ref-for-ascii-case-insensitive-78">ASCII
    case-insensitive</a> match for the string "<code>xml</code>".
      </li><li>A <code>ProcessingInstruction</code> node whose target name contains a U+003A COLON (:).
      </li><li>A <code>ProcessingInstruction</code> node whose data contains the string "<code>?&gt;</code>".
     </li></ul>
     <p class="note" role="note"> These are the only ways to make a DOM unserialisable. The DOM enforces all the
  other XML constraints; for example, trying to append two elements to a <code>Document</code> node
  will throw a <code>HierarchyRequestError</code> exception. </p>
     <h3 class="heading settled" data-level="9.4" id="parsing-xhtml-fragments"><span class="secno">9.4. </span><span class="content">Parsing XHTML fragments</span><a class="self-link" href="xhtml.html#parsing-xhtml-fragments"></a></h3>
     <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="xml-fragment-parsing-algorithm">XML fragment parsing algorithm</dfn> either returns a <code>Document</code> or throws
  a "<code class="idl"><a data-link-type="idl" href="http://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>. Given a string <var>input</var> and a
  context element <var>context</var>, the algorithm is as
  follows:</p>
     <ol>
      <li>
       <p>Create a new <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-33">XML parser</a>.</p>
      </li><li>
       <p><a data-link-type="dfn" href="xhtml.html#feed-the-parser" id="ref-for-feed-the-parser-1">Feed the
    parser</a> just created the string corresponding to the start tag of the <var>context</var> element, declaring
    all the namespace prefixes that are in scope on that element in the DOM, as well as declaring
    the default namespace (if any) that is in scope on that element in the DOM.</p>
       <p>A namespace prefix is in scope if the DOM <code>lookupNamespaceURI()</code> method
    on the element would return a non-null value for that prefix.</p>
       <p>The default namespace is the namespace for which the DOM <code>isDefaultNamespace()</code> method on the element would return true.</p>
       <p class="note" role="note"> No <code>DOCTYPE</code> is passed to the parser, and therefore no external subset is
    referenced, and therefore no entities will be recognized. </p>
      </li><li>
       <p><a data-link-type="dfn" href="xhtml.html#feed-the-parser" id="ref-for-feed-the-parser-2">Feed the parser</a> just created the string <var>input</var>.</p>
      </li><li>
       <p><a data-link-type="dfn" href="xhtml.html#feed-the-parser" id="ref-for-feed-the-parser-3">Feed the parser</a> just created the string corresponding to the end tag of the <var>context</var> element.</p>
      </li><li>
       <p>If there is an XML well-formedness or XML namespace well-formedness error, then throw a
    "<code class="idl"><a data-link-type="idl" href="http://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these steps.</p>
      </li><li>
       <p>If the root
    element of the resulting <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has any sibling nodes, then throw a
    "<code class="idl"><a data-link-type="idl" href="http://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these steps.</p>
      </li><li>
       <p>Return the
    child nodes of the root element of the resulting <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, in <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-82">tree
    order</a>.</p>
     </li></ol>
    </div>
   </section></main>
  
<script src="js/fixup.js"></script>
  

<p class="prev_next">← <a href="syntax.html#syntax"><span class="secno">8</span> <span class="content"><span>The HTML syntax</span></span></a> — <a href="index.html#contents">Table of contents</a> — <a href="rendering.html#rendering"><span class="secno">10</span> <span class="content">Rendering</span></a> →</p></body></html>
